package com.xujl.mvcbind.ui.element.control;

import android.os.Bundle;
import android.view.View;

import com.xujl.fastlib.base.BaseFragment;
import com.xujl.mvcbind.ui.element.DetailElement;
import com.xujl.mvcbind.ui.element.FormElement;
import com.xujl.mvcbind.ui.element.ListElement;
import com.xujl.mvcbind.ui.element.model.ElementTestOneFragmentModel;
import com.xujl.mvcbind.ui.element.view.ElementTestOneFragmentView;

/**
 * <pre>
 *     author : xujl
 *     e-mail : 597355068@qq.com
 *     time   : 2019/08/20
 *     desc   :
 *     version: 1.0
 * </pre>
 */

public class ElementTestOneFragmentControl extends BaseFragment<ElementTestOneFragmentModel, ElementTestOneFragmentView> {
    private ListElement mListElement;
    private FormElement mFormElement;
    private DetailElement mDetailElement;

    @Override
    public void init (Bundle savedInstanceState) {
        mListElement = new ListElement(mView.getBind().vsList.getViewStub());
        mListElement.initView();
        mListElement.refreshData(mModel.getListData());
        mFormElement = new FormElement(mView.getBind().vsForm.getViewStub());
        mFormElement.initView();
        mDetailElement = new DetailElement(mView.getBind().vsDetail.getViewStub());
        mDetailElement.initView();
        mDetailElement.setData(mModel.getDetailsData());
    }

    @Override
    public void onClick (View view) {
        super.onClick(view);
        String listData = mListElement.getCheckData();
        String formData = mFormElement.getInputData();
        mView.toast(listData + "\n" + formData);
    }

    public static ElementTestOneFragmentControl newInstance () {

        Bundle args = new Bundle();

        ElementTestOneFragmentControl fragment = new ElementTestOneFragmentControl();
        fragment.setArguments(args);
        return fragment;
    }
}
